import requests
import json

# Nomic服务地址
NOMIC_API_URL = "http://127.0.0.1:3000/api/embeddings"

# 要embed的文本
text_to_embed = "这是一个测试句子，用来验证Nomic embedding功能。"

# 准备请求数据
data = {
    "model": "nomic-embed-text:latest",
    "prompt": text_to_embed
}

# 发送请求
response = requests.post(NOMIC_API_URL, json=data)

# 检查响应
if response.status_code == 200:
    result = response.json()
    print("Embedding成功！")
    print(f"文本: {text_to_embed}")
    print(f"Embedding向量长度: {len(result.get('embedding', []))}")
    print(f"前10维向量值: {result.get('embedding', [])[:10]}")
else:
    print(f"请求失败，状态码: {response.status_code}")
    print(response.text)